/**
 * 
 */
package uicgas.globaldevice;

import java.util.Random;

import javax.swing.JOptionPane;

import uicgas.globaldata.Transaction;

/**
 * @author Steve
 *
 */
public class MockPrinter implements Printer
{
	private Random random = new Random();

	public void print()
	{
		JOptionPane.showMessageDialog(null,
				"System is now printing the requested receipt.",
				"Print Receipt", JOptionPane.INFORMATION_MESSAGE);
	}

	public void print(Transaction CurrentTransaction)
	{
		JOptionPane.showMessageDialog(null,
				"System is now printing the requested receipt. \n"
						+ CurrentTransaction.toPrint(), "Print Receipt",
				JOptionPane.INFORMATION_MESSAGE);
	}

	@Override
	public boolean printWithProbabilityFailed(Transaction CurrentTransaction)
	{
		if (random.nextBoolean())
		{
			print(CurrentTransaction);
			return true;
		}

		return false;
	}
}
